package org.example.BQ;

import java.util.Collection;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

public class blockingQueueTest {
    public static void main(String[] args) throws InterruptedException {
       test3();
    }
    public static void test(){
        ArrayBlockingQueue abq = new ArrayBlockingQueue(3);

        System.out.println(  abq.add("a"));
        System.out.println(  abq.add("b"));
        System.out.println(  abq.add("c"));
        System.out.println("----------------------------------");

        System.out.println("=================================");

        System.out.println(abq.remove());
        System.out.println(abq.remove());
        System.out.println(abq.remove());
        System.out.println(abq.element());


    }
    public static void test1()   {
        ArrayBlockingQueue abq = new ArrayBlockingQueue(3);

        System.out.println(abq.offer("a"));
        System.out.println(abq.offer("b"));
        System.out.println(abq.offer("c"));

        System.out.println("---------------------");

        System.out.println(abq.poll());
        System.out.println(abq.poll());
        System.out.println(abq.poll());
        System.out.println(abq.peek());



    }
    public static void test2() throws InterruptedException {
        ArrayBlockingQueue abq = new ArrayBlockingQueue(3);

        abq.put("a");
        abq.put("b");
        abq.put("c");
        System.out.println("----------------");
        System.out.println(abq.take());
        System.out.println(abq.peek());
        System.out.println(abq.take());
        System.out.println(abq.take());



    }
    public static void test3() throws InterruptedException {
        ArrayBlockingQueue abq = new ArrayBlockingQueue(3);
        System.out.println(abq.offer("a", 2, TimeUnit.SECONDS));
        System.out.println(abq.offer("b", 2, TimeUnit.SECONDS));
        System.out.println(abq.offer("c", 2, TimeUnit.SECONDS));
        System.out.println("----------------------------------------------");
        System.out.println(abq.poll(2, TimeUnit.SECONDS));
        System.out.println(abq.poll(2, TimeUnit.SECONDS));
        System.out.println(abq.poll(2, TimeUnit.SECONDS));
        System.out.println(abq.poll(2, TimeUnit.SECONDS));

    }
}
